package dao;

import java.util.List;

import hbt.HibernateDAO;

import org.hibernate.Session;
import org.hibernate.Transaction;

import bean.PlatoBean;

public class PlatoDao {

	public void altaPlato(PlatoBean P)
	{
		Session s = HibernateDAO.getInstancia().getSession();
		Transaction t = s.beginTransaction();
		s.persist(P);
		t.commit();
	}

	@SuppressWarnings("unchecked")
	public List<PlatoBean> listaPlatoDelLocal(int local) {
		Session s = HibernateDAO.getInstancia().getSession();
		Transaction t = s.beginTransaction();
		List<PlatoBean> platos = (List<PlatoBean>)s.createQuery("select p from LocalBean l inner join l.carta c inner join c.Platos p where l.idLocal = ?").setInteger(0,local).list();
		t.commit();
		return platos;
	}
	
}

